﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OOLib
{
   /// <summary>
   /// Provides functionality to enumerate the contents of a container.
   /// </summary>
   public class Enumeration : ComObjectWrapper, IEnumeration
   {
      #region Constructors

      /// <summary>
      /// Constructor
      /// </summary>
      /// <remarks>
      /// After using this constructor, the ComObj must be set manually!
      /// </remarks>
      public Enumeration() :
         base()
      { }

      /// <summary>
      /// Constructor
      /// </summary>
      /// <param name="comObject">COM object</param>
      public Enumeration(object comObject) :
         base(comObject)
      { }

      #endregion

      #region IEnumeration

      /// <summary>
      /// Gets whether this enumeration contains more elements. 
      /// </summary>
      /// <remarks>!!! Not tested !!!</remarks>
      public bool HasMoreElements 
      { 
         get
         {
            CheckDisposed();
            return (bool)InvokeMethod("hasMoreElements");
         }
      }

      /// <summary>
      /// Returns the next element of this enumeration.
      /// </summary>
      /// <returns>Returns the next element of this enumeration.</returns>
      /// <remarks>!!! Not tested !!!</remarks>
      public object NextElement()
      {
         CheckDisposed();
         return InvokeMethod("nextElement");
      }

      #endregion
   }

   /// <summary>
   /// Provides functionality to enumerate the contents of a container. 
   /// </summary>
   /// <remarks>
   /// An object that implements the XEnumeration interface generates a series of elements, one at a time. 
   /// Successive calls to the XEnumeration::nextElement method return successive elements of the series. 
   /// For example (Java), to print all elements of a vector aVect: 
   /// for ( XEnumeration xEnum = aVect.elements() ; 
   /// xEnum.hasMoreElements() ; ) 
   /// {
   ///   System.out.println( xEnum.nextElement() );
   /// }
   /// If the object changed, the behavior of the enumeration is not specified. This is not a remote interface. 
   /// </remarks>
   public interface IEnumeration
   {
      /// <summary>
      /// Gets whether this enumeration contains more elements. 
      /// </summary>
      bool HasMoreElements { get; }

      /// <summary>
      /// Returns the next element of this enumeration.
      /// </summary>
      /// <returns>Returns the next element of this enumeration.</returns>
      object NextElement();
   }
}
